class ThematicsController < ApplicationController

  load_and_authorize_resource

  def selector_thematics_list
      @thematics = Thematic.search_selector(params[:search_name], params[:page])
      render :partial=>'thematics/selector_thematics_list', :locals => {:search_name => params[:search_name]} , :layout=>false
  end

  def selector_thematics_list_from_paginate
      @thematics = Thematic.search_selector(params[:search_name], params[:page])
  end

  # GET /thematics
  # GET /thematics.xml
  def index
    @thematics = Thematic.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @thematics }
    end
  end

  # GET /thematics/1
  # GET /thematics/1.xml
  def show
    @thematic = Thematic.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @thematic }
    end
  end

  # GET /thematics/new
  # GET /thematics/new.xml
  def new
    @thematic = Thematic.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @thematic }
    end
  end

  # GET /thematics/1/edit
  def edit
    @thematic = Thematic.find(params[:id])
  end

  # POST /thematics
  # POST /thematics.xml
  def create
    @thematic = Thematic.new(params[:thematic])

    respond_to do |format|
      if @thematic.save
        flash[:notice] = 'Thematic was successfully created.'
        format.html { redirect_to(@thematic) }
        format.xml  { render :xml => @thematic, :status => :created, :location => @thematic }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @thematic.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /thematics/1
  # PUT /thematics/1.xml
  def update
    @thematic = Thematic.find(params[:id])

    respond_to do |format|
      if @thematic.update_attributes(params[:thematic])
        flash[:notice] = 'Thematic was successfully updated.'
        format.html { redirect_to(@thematic) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @thematic.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /thematics/1
  # DELETE /thematics/1.xml
  def destroy
    @thematic = Thematic.find(params[:id])
    @thematic.destroy

    respond_to do |format|
      format.html { redirect_to(thematics_url) }
      format.xml  { head :ok }
    end
  end
end
